/*------------------------------ include -------------------------------------*/
/**
 * *****************************************************************
 * @file    adt3102_gpio.h
 * @author  WuHao(hwu@andartechs.com.cn)
 * @version 1.0.0
 * @date    2020-11-04
 * @brief
 *
 *                 Copyright (c) 2020, Andar Technologies Inc.
 *                           www.andartechs.com 
 *
 * *****************************************************************
 */
#ifndef __GPIO_H
#define __GPIO_H

/*------------------------------ include -------------------------------------*/
#include "adt3102_type_define.h"


/*------------------------------ function ------------------------------------*/
/* GPIOx :gpio ID select */
#define GPIO0 0
#define GPIO1 1
#define GPIO2 2
#define GPIO3 3
#define GPIO4 4
#define GPIO5 5
#define GPIO6 6
#define GPIO7 7
#define GPIO8 8
#define GPIO9 9
#define GPIO10 10
#define GPIO11 11
#define GPIO12 12
#define GPIO13 13
#define GPIO14 14
#define GPIO15 15
#define GPIO16 16
#define GPIO17 17
#define GPIO18 18
#define GPIO19 19
#define GPIO20 20
#define GPIO21 21
#define GPIO22 22
#define GPIO23 23
#define GPIO24 24
#define GPIO25 25
#define GPIO26 26
#define GPIO27 27
#define GPIO28 28
#define GPIO29 29
#define GPIO30 30

/*
HIGH_LEVEL : gpio output high level
LOW_LEVEL : gpio output low level
*/
#define HIGH_LEVEL 1
#define LOW_LEVEL 0

/*
edge_triggered : gpio interrput edge triggered
level_triggered :gpio interrput level triggered
*/
#define edge_triggered  1
#define level_triggered 0


/*------------------------------ function ------------------------------------*/
/**
 * @brief   GPIO set as high-z with pull up or pull down.
 * @param   pinNumber: gpio number.
 * @param   pinUpDown: GPIO set as high-z with pull up or pull down, 1:pullUp, 0:pullDown.
 * @return  None.
 * @note
 */
void gpioPullUpDown(uint32 pinNumber,uint8 pinUpDown);

/**
 * @brief   GPIO set output high or low level.
 * @param   pinNumber: gpio number.
 * @param   pinUpDown: 1: high level  0: low level.
 * @return  None.
 * @note
 */
void gpioOutput(uint32 pinNumber,uint8 pinLeve);

/**
 * @brief   get gpio status.
 * @param   pinNumber: gpio number.
 * @return  1: high level  0: low level.
 * @note
 */
int32 getGpioStatus(uint32 pinNumber);

/**
 * @brief   GPIO set output high or low level.
 * @param   pinNumber: gpio number.
 * @param   pinDirection: GPIO set output or input or high inpendence
 *                     0:output
 *                     1:input
 *                     2:high inpendence
 *                     3:output & input
 * @return  None.
 * @note
 */
void gpioDirection(uint32 pinNumber,uint32 pinDirection);

/**
 * @brief   get gpio status.
 * @param   pinNumber: gpio number.
 * @return  0:output
 *          1:input
 *          2:high inpendence
 * @note
 */
int32 getGpioDirection(uint32 pinNumber);

/**
 * @brief   set Gpio iunterrupt.
 * @param   Pin_number: .
 * @param   trigger_mode: GPIO trigger mode 1:edge  triggered
 *                          0:level triggered.
 * @param   trigger_pol: GPIO trigger pol   1:posedge or high level*
 *                                          0:negedge or low  level*.
 * @return  None.
 * @note
 */
typedef void (*gpioCallback)(void *gpioArg);
extern gpioCallback gpioSetEnintC(uint32 pinNumber,uint32 triggerMode,uint32 triggerPol, gpioCallback gpioFunc,void *data);
void gpioSetEnint(uint32 pinNumber,uint32 triggerMode,uint32 triggerPol);
void gpioDisableint(uint32 pinNumber);

#endif


